package com.ideaction.entity.mail.filter;

import com.ideaction.entity.mail.BaseMail;

import java.util.Map;

/**
 * 邮件筛选器
 *
 * @author ZGame
 */
public abstract class MailFilter {
    
    protected static int DELETE_STATUS = 3;// 删除状态
    
    protected MailFilter nextMatch;
    
    protected abstract boolean filtJudge(BaseMail mail, Map<String, Integer> mailStatus, String... params);
    
    public final boolean canShow(BaseMail mail, Map<String, Integer> mailStatus, String... params) {
        // 自己首先筛选
        if (filtJudge(mail, mailStatus, params)) {
            return false;
        }
        // 开始责任链筛选
        if (nextMatch != null) {
            return !nextMatch.filtJudge(mail, mailStatus);
        }
        
        return true;
    }
}
